from django.db import models
from django.contrib.auth.models import User


# 留言消息
class Message(models.Model):
    user = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE)
    user_message = models.CharField('用户消息', max_length=100, blank=True)
    admin_message = models.CharField('管理员消息', max_length=100, blank=True)
    create_time = models.DateTimeField('会话发起时间', auto_now_add=True)
    update_time = models.DateTimeField('最后回复时间', auto_now=True)

    class Meta:
        db_table = 'message'
        verbose_name = '留言'
        verbose_name_plural = '留言'

    def __str__(self):
        return self.user.username

